package org.kisekiproject.classlibrary {
	public class CompoundClassLibrary implements IClassLibrary {

		private var _libraries:Array;

		/**
		 * Constructor.
		 */
		public function CompoundClassLibrary() {
			_libraries=new Array();
		}

		/**
		 * Get class.
		 */
		public function getClass(name:String):Class {
			for each (var library:IClassLibrary in _libraries)
				if (library.hasClass(name))
					return library.getClass(name);
			
			throw new Error("Class does not exist: "+name);
		}

		/**
		 * Does the class exist?
		 */
		public function hasClass(name:String):Boolean {
			for each (var library:IClassLibrary in _libraries)
				if (library.hasClass(name))
					return true;

			return false;
		}

		/**
		 * Add a class library.
		 */
		public function addClassLibrary(library:IClassLibrary):void {
			_libraries.push(library);
		}
	}
}